// 写入SID
var sid;
var iframeNmae = (window.frameElement && window.frameElement.id) || "noIframe";
if (iframeNmae == "iframe") {
    //查看定制项目
} else if (iframeNmae == "iframe2") {
    //修改定制项目
} else if (iframeNmae == "iframe3") {
    //新增定制项目
    sid = $("#iframe3").attr("sid") || Date.now();
    $("#sid").html(sid);
} else if (iframeNmae == "noIframe") {
    //单独查看
}

var cname = getCookie("cname");
// 隐藏登陆新状态栏
$("input[name='engineer']").val(cname);
if (self.frameElement && self.frameElement.tagName == "IFRAME") {
    $(".addDesigHeader").hide();
    $("#topHeader").css("height", "10px");
}

// 一、.添加新柜型钣金成本
var banjinNB = 1; //添加新柜型钣金核算成本
$("body ").on("click", "#addbtn", function(e) {
    var e = event || window.event;
    e.preventDefault();
    var str =
        ` <tr>  
     <td class="text-center ">
         <input type="number" class="form-control boxType   " name="xuhao` +
        banjinNB +
        `" disabled value="` +
        banjinNB +
        `" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type = "text"
         class = "form-control boxType notnull"
         name = "boxName` +
        banjinNB +
        `"` +
        `placeholder="柜型` +
        banjinNB +
        `"value="" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="metalCost` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="banjinjiagongfei` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="dianyongfei` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="pengtufei` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="wujin` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="chaungkoucaizhi` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="pibicaizhi` +
        banjinNB +
        `" value="0" placeholder=" ">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" name="kaimo` +
        banjinNB +
        `" value="0" placeholder="">
     </td>
      <td class="col-md text-center ">
         <input type="number" class="form-control boxType" name="qitafei` +
        banjinNB +
        `" value="0" placeholder="其他费">
     </td>
     <td class=" col col-md-1 text-center ">
         <input type="number" class="form-control boxType" disabled name="banjinhanshi` +
        banjinNB +
        `" value="0" placeholder="含税小计">
     </td>
     <td class="col-md-1 text-center ">
         <input type="number" class="form-control boxType" disabled name="banjinbuhanshui` +
        banjinNB +
        `" value="0" placeholder="不含税小计">
     </td>
 </tr>`;

    //  二、添加柜型时候绑定添加电控成本list容器
    if (banjinNB <= 10) {
        var table = $(this).prev("table");
        var parsnetH = $(table).height() + 50;
        // var parsnetH = $('.table1').height() + 50;
        $("#addbtn").css("top", parsnetH + "px");
        $("#renGongAddbtn").css("top", parsnetH + "px");
        $("#outPriceAddbtn").css("top", parsnetH + "px");
        $("#tbody0").append(str);
        // 电控件新增柜型成套柜型电控物料
        var boxsCount = $("#tbody0 tr").length || banjinNB;

        var diankogTrNB = banjinNB + 1;
        // console.log(diankogTrNB, banjinNB);
        var deviceStr =
            ` <div class="form-group  banjinGroup col-md-12 bangjing device" id="device` +
            banjinNB +
            `" title="二、主要柜型电控件成本清单"
                        style=" border-right: 2px sandybrown dashed;margin-bottom: 2px;">
                        <div class="form-group jiegouhesuan col-lg-8 ">
                            <table
                                class="table table2 table-bordered table-striped table-hover table-condensed table-responsive">
                                <caption class="table-border tableTitel" border="1" align="top">
                                    二、主要电控成本明细-<label>柜型` +
            banjinNB +
            `</label>
                                </caption>
                                <thead>
                                    <tr>
                                        <th class="text-center  col  col-md-01 " style="width: 50px;">#</th>
                                        <th class="text-center col  col-md-1">物料品号</th>
                                        <th class="text-center   col col-md-3  ">物料名称</th>
                                        <th class="text-center  col  col-md-1  ">单位</th>
                                        <th class="text-center  col  col-md-1  ">用量</th>
                                        <th class="text-center col   col-md-1  ">含税单价</th>
                                        <th class="text-center  col  col-md-1  ">含税小计</th>
                                        <th class="text-center  col  col-md-3  ">备注</th>
                                    </tr>
                                </thead>
                                <tbody class='deviceTbody' id="tbody` +
            (diankogTrNB + 0) +
            `" dainkongNB=` +
            diankogTrNB +
            `>
                                <!-- 存放新添加物料-->
                                </tbody>
                                <tbody>
                                    <tr class="diankongPriceTotal  ">
                                        <td class="     text-center"><label style="padding: 0;margin: 0;">含税合计:</label>
                                        </td>
                                        <td class="   text-center  "> <input type = "number" disabled class = "form-control  device" name = "hanshuiheji` +
            diankogTrNB +
            `" value="" placeholder="0">
                                        </td>
                                        <td class="   text-center"><label style="padding: 0;margin: 0;">不含税合计:</label>
                                        </td>
                                        <td class="     text-center  ">
                                            <input type = "number" disabled
                                            class = "form-control  device buHanShuiDidankong"
                                            name = "buhanshuiheji` +
            diankogTrNB +
            `"
                                                value="" placeholder="0">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <button type="button" class="btn btn-success addbtn deviceAddbtn " id="deviceAddbtn` +
            diankogTrNB +
            `">添加行</button>
                        </div>
                        <div class=" col-lg-4 infoJpg  " id="infoJpg` +
            diankogTrNB +
            `" style="white-space: normal;">
                            <div class="simgDiv" id="simgDiv` +
            diankogTrNB +
            `">
                                <label>参考截图</label>
                                <img type="img" alt="可直接拖入图片↓" class="form-control boxImg  " name="boxImg1">
                                <input type="text" class="infoJpg infoJpgInput" name="infoJpgInput` +
            diankogTrNB +
            `">
                                <span class="glyphicon glyphicon-open imgChange btn btn-info imgChange2 imgChange3">替换</span>
                               <!-- <span class="glyphicon glyphicon-zoom-in tobig  btn btn-primary tobig2">放大</span> -->
                        </div>
                    </div>`;
        if (boxsCount >= 2) {
            //第一个柜型不添加电控list
            $("#device").append(deviceStr);
        }

        // ---------------三、添加钣金柜型时候添加材料核算汇总--------------//
        var costTotalStr =
            `  <tr title="财务或生产部提供数据">
                                    <td class=" col  text-center ">
                                        <input type="number" class="form-control boxType" disabled name="hejixuhao` +
            banjinNB +
            `"
                                            value="` +
            banjinNB +
            `" placeholder="1 ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "text"
                                        class = "form-control boxType"
                                        name = "hejiboxName` +
            banjinNB +
            `" value=""
                                            placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"
                                        class = "form-control boxType readonly" disabled
                                        name = "hejibanjin` +
            banjinNB +
            `" value="0"
                                            placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"
                                        class = "form-control boxType" disabled
                                        name = "hejidiankong` +
            banjinNB +
            `"
                                            title="单柜型电控成本" value="0" placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"
                                        class = "form-control boxType"disabled
                                        name = "hejixiancai` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"
                                        class = "form-control boxType"disabled
                                        name = "hejibaocai` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"
                                        class = "form-control boxType"
                                        name = "hejiqita` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"disabled
                                        class = "form-control boxType"
                                        name = "hejihanshui` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="含税">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type = "number"disabled
                                        class = "form-control boxType"
                                        name = "hejibuhanshui` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="不含税">
                                    </td>
                                     <td class="col-md-2 text-center ">
                                        <input type = "text"
                                        class = "form-control boxType"
                                        name = "hejibeizhu` +
            banjinNB +
            `" value=""
                                            placeholder=" " title="备注">
                                    </td>
                                </tr>`;

        $("#costTotalTbody").append(costTotalStr);

        //  ---------四、跟进钣金柜型添加对应的人工------------//
        var rengongStr =
            ` <tr title="财务或生产部提供数据">
                                    <td class=" col  text-center ">
                                        <input type="number" class="form-control boxType" disabled name="rgxuhao` +
            banjinNB +
            ` "
                                            value="` +
            banjinNB +
            `" placeholder="1 ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="text" class="form-control boxType" name="rgboxName` +
            banjinNB +
            `" value=""
                                            placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="rgcount` +
            banjinNB +
            `" value="0"
                                            placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="PurchasingTime` +
            banjinNB +
            `"
                                            title="采购下料工时(分钟)" value="0" placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="bendingTime` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="weldingTime` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="sprayingTime` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="assemblyTime` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="testTime` +
            banjinNB +
            `" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="totalTime` +
            banjinNB +
            `" value="0"
                                            placeholder="" title="小时">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="ArtificialCost` +
            banjinNB +
            `"
                                            value="0" placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" name="ManufacturingExpense` +
            banjinNB +
            `"
                                            value="0" placeholder="">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType" disabled name="rengongTotal` +
            banjinNB +
            `" value="0"
                                            placeholder="">
                                    </td>
                                </tr>`;

        $("#renGongTbody").append(rengongStr);
        var banjinNB2 = banjinNB + 0;
        //---------------五、新增阶梯柜型-----------------------//
        var jietiStr1 = //阶梯1
            ` <tr title=" ">
                                        <td class=" col  text-center ">
                                            <input type="number" class="form-control boxType" disabled name="jietixuHao` +
            banjinNB2 +
            `"
                                                value="` +
            banjinNB2 +
            `" placeholder="1 ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="text" class="form-control boxType" name="jietiboxName` +
            banjinNB2 +
            `" value=""
                                                placeholder="" title="柜型名称">
                                        </td>
                                        <td class="col-md-1 text-center " title="材料费不含税">
                                            <input type="number" class="form-control boxType"disabled name="jietibuhanshuiCaiLiao` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center " title="人工制费">
                                            <input type="number" class="form-control boxType"disabled name="jietirengGong` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jietizongChenBenbuhanshui` +
            banjinNB2 +
            `"
                                                title="不含税总成本" value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled  name="jietizongChenBenHanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="含税总成本">
                                        </td>
                                        <td class="col-md col text-center ">
                                            <input type="number" class="form-control boxType" name="jietimaoLilv` +
            banjinNB2 +
            `" value="40" placeholder="40"  title="毛利率1">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jietihanshuibaojia` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jietiwuLiuYunShu` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jietibanYunZhuangXie` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jietizhibao` +
            banjinNB2 +
            `" value="0"
                                                placeholder="0.02" title="分钟">
                                        </td>
                                       
                                        <td class="col-md-1text-center ">
                                            <input type="numbel" class="form-control boxType"disabled name="jietiduiwaibaojia` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="对外报价">
                                        </td>
                                          <td class="col-md-2 text-center ">
                                            <input type="text" class="form-control boxType" name="jietibeizhu` +
            banjinNB2 +
            `"
                                                value="" placeholder=" " title="阶梯一备注">
                                        </td>
                                    </tr>`;

        // 阶梯2

        var jietiStr2 =
            ` <tr title=" ">
                                        <td class=" col  text-center ">
                                            <input type="number" class="form-control boxType" disabled name="jieti2xuhao` +
            banjinNB2 +
            `"
                                                value="` +
            banjinNB2 +
            `" placeholder="1 ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="text" class="form-control boxType" name="jieti2boxName` +
            banjinNB2 +
            `" value=""
                                                placeholder="" title="柜型名称">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="text" class="form-control boxType"disabled name="jieti2yuanCaiLiaobuhanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieti2rengGongbuhanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieti2zongChenBenbuhanshui` +
            banjinNB2 +
            `"
                                                title="采购下料工时(分钟)" value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit2zongChenBenBHanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md col text-center ">
                                            <input type="number" class="form-control boxType"    name="jieti2maoLilv` +
            banjinNB2 +
            `" value="40" placeholder="40" title="毛利率2">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieti2salsePriceHangShui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="不含税毛利报价后加含税">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jieti2wuLiuYunShu` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jieti2banYunZhuangXie` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieti2zhibao` +
            banjinNB2 +
            `" value="0"
                                                placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit2outPrice` +
            banjinNB2 +
            `" value="0"
                                                placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-2 text-center ">
                                            <input type="text" class="form-control boxType" name="jieit2beizhu` +
            banjinNB2 +
            `"
                                                value="" placeholder=" " title="备注">
                                        </td>
                                    </tr>`;

        // 阶梯3

        var jietiStr3 =
            `<tr title="">
                                        <td class=" col  text-center ">
                                            <input type="number" class="form-control boxType" disabled name="jieti3xuHao` +
            banjinNB2 +
            `"
                                                value="` +
            banjinNB2 +
            `" placeholder="1 ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="text" class="form-control boxType" name="jieit3boxName` +
            banjinNB2 +
            `" value=""
                                                placeholder="" title="柜型名称">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="text" class="form-control boxType"disabled name="jieit3yuanCaiLiaobuhanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3rengGongbuhanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3zongChenBenbuhanshui` +
            banjinNB2 +
            `"
                                                title="采购下料工时(分钟)" value="0" placeholder=" ">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3zongChenBenHanshui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md col text-center ">
                                            <input type="number" class="form-control boxType" name="jieit3maoLilv` +
            banjinNB2 +
            `" value="40" placeholder="40"  title="毛利率3">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3salsePriceHangShui` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jieit3wuLiuYunShu` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType" name="jieit3banYunZhuangXie` +
            banjinNB2 +
            `"
                                                value="0" placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3zhibao` +
            banjinNB2 +
            `" value="0"
                                                placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-1 text-center ">
                                            <input type="number" class="form-control boxType"disabled name="jieit3outPrice` +
            banjinNB2 +
            `" value="0"
                                                placeholder=" " title="分钟">
                                        </td>
                                        <td class="col-md-2 text-center ">
                                            <input type="text" class="form-control boxType" name="jieit3beizhu` +
            banjinNB2 +
            `"
                                                value="" placeholder=" " title="阶梯三备注">
                                        </td>
                                    </tr>`;

        $(".count0").append(jietiStr1);
        $(".count50").append(jietiStr2);
        $(".count300").append(jietiStr3);
        // $('#outPrice1Total').append(outPriceTotal);//
        // $('#outPriceAddbtn').trigger('click');//顺便添加总对外报价项目
        // $('#outPriceAddbtn').click();//顺便添加总对外报价项目
        outPriceAddbtn(); //添加硬件对外推荐报价
        banjinNB++;
        // dinakongNB++;
    } else Toast("注意：最多添加十个柜型!再多请重添加另外一个新项目。", "warning", 2000, 2000);
});

// ------------------------------//六、硬件对外推荐报价 添加对外报价净利润汇总   ---------------------//
// 单独添加汇总报价
var outPriceNB = 1;
$("#outPriceAddbtn").click(function(e) {
    var e = event || window.event;
    e.preventDefault();
    var table = $(this).prev("table");
    var parsnetH = $(table).height() + 50;
    $("#outPriceAddbtn").css("top", parsnetH + "px");
    outPriceAddbtn();
});

function outPriceAddbtn() {
    var outPriceTotal =
        `  <tr title=" ">
                                    <td class=" col  text-center ">
                                        <input type="number" class="form-control boxType" disabled name="rgxuhao` +
        outPriceNB +
        ` "
                                            value="` +
        outPriceNB +
        `" placeholder="1 ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="text" class="form-control boxType "  name="rgboxName1" value=""
                                            placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="text" class="form-control boxType size" name="dwsize" value=""
                                            placeholder="W1420*H1880*D450">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="bhszcb"
                                            title="单台不含税总成本" value="0" placeholder=" ">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="hszcb" value="0"
                                            placeholder=" " title="单台含税总成本">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType "disabled name="xstc" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="jinlirun" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="jinlilv" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col  text-center ">
                                        <input type="number" class="form-control boxType"  name="boxSalseCount" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="baojiaxiaoji" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="number" class="form-control boxType"disabled name="jinlirunxj" value="0"
                                            placeholder=" " title="分钟">
                                    </td>
                                    <td class="col-md-1 text-center ">
                                        <input type="text" class="form-control boxType" disabled name="xiaojibeizhu" value=""
                                            placeholder=" " title="备注">
                                    </td>
                                </tr>`;

    $("#duiwaituijianbaojia").append(outPriceTotal);
    outPriceNB++;
    // console.log(outPriceNB)
}
// ------------------------------//六、硬件对外推荐报价 添加对外报价净利润汇总 结束---------------------//

// ------------------------七、添加技术服务费项目  serviceTbody----------------------------//
var serviceNB = 1;
$("body").on("click", "#serviceAdd", function(e) {
    var e = event || window.event;
    e.preventDefault();
    var table = $(this).prev("table");
    var parsnetH = $(table).height() + 50;
    $("#serviceAdd").css("top", parsnetH + "px");
    var serviceStr =
        ` <tr title="评估技术开发费用">` +
        `
                                    <td class=" col  text-center ">` +
        `
                                        <input type="number" class="form-control boxType" disabled name="servicexuhao` +
        serviceNB +
        ` "` +
        `
                                            value="` +
        serviceNB +
        `" placeholder="1 ">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type="text" class="form-control boxType" name="serviceName` +
        serviceNB +
        `" value=""` +
        `
                                            placeholder="软件或硬件开发费">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-2 text-center ">` +
        `
                                        <input type="text" class="form-control boxType titelToast" name="serviceInfo` +
        serviceNB +
        `" value=""` +
        `
                                            placeholder="几款软件或柜型设计开发">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type="number" class="form-control boxType" name="servicecost` +
        serviceNB +
        `"` +
        `
                                            title="人天工时" value="0" placeholder=" ">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type="number" class="form-control boxType" name="salseTime` +
        serviceNB +
        `" value="0"` +
        `
                                            placeholder=" " title="分钟">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type="number" class="form-control boxType" disabled name="servicePrice` +
        serviceNB +
        `" value="0"` +
        `
                                            placeholder=" " title="成本金额">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type="number" class="form-control boxType" name="serviceRote` +
        serviceNB +
        `" value="0"` +
        `
                                            placeholder=" " title="分钟">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        
                                        <input type="number" class="form-control boxType"disabled name="totalPrice` +
        serviceNB +
        `" value="0"` +
        `
                                            placeholder=" " title="对外报价小计">` +
        `
                                    </td>
                                    <td class="col-md-1 text-center ">` +
        `
                                         <input type="number" class="form-control boxType"disabled name="serverRote` +
        serviceNB +
        `" value="0"` +
        `
                                            placeholder="" title="服务费毛利率">` +
        `
                                    </td>` +
        `
                                    <td class="col-md-1 text-center ">` +
        `
                                        <input type = "text"
                                        class = "form-control boxType titelToast"
                                        name = "infoAther` +
        serviceNB +
        `" value=""` +
        `
                                            placeholder=" ">` +
        `
                                    </td>` +
        `
                                </tr>`;
    $("#serviceTbody").append(serviceStr);
    serviceNB++;
});
// ==========================七，结束，第八在计算js中=================================

//------------------二、2.添加新柜型电控成本物料项目-------------------//
var addbtn = $(".addbtn");
var dainkongNB;
$("body").on("click", ".deviceAddbtn", function(e) {
    //每套柜型单独添加电控物料
    var e = event || window.event;
    e.preventDefault();
    var index = $(this).index();
    // alert(e);
    // console.log(e, index)
    var thisTbody = $(this).prev("table").children(".deviceTbody");
    // console.log(thisTbody);
    // });
    // $('#addbtn1').click(function (e) {
    dainkongNB = parseInt($(this).prev("table").children(".deviceTbody").children("tr").last().attr("dainkongnb"));
    // console.log(dainkongNB)
    if (dainkongNB < 1 || isNaN(dainkongNB)) {
        dainkongNB = 0;
        // console.log(dainkongNB);
    }
    dainkongNB++;
    // | 1;

    var e = e || window.e;
    e.preventDefault();

    if (dainkongNB <= 20) {
        var str2 =
            `<tr dainkongNB=` +
            dainkongNB +
            ` >
       <td class=" col  text-center "  >
       <input type="number" class="form-control  device" disabled name="xuhao` +
            dainkongNB +
            ` " value="` +
            dainkongNB +
            `" placeholder="">
       </td>
       <td class="col-md-1 text-center ">
           <input type="number" class="form-control device boxSN" name="SN` +
            dainkongNB +
            `" value="" placeholder="9120202">
       </td>
       <td class="col-md-1 text-center ">
           <input type="text" class="form-control   device" name="snName` +
            dainkongNB +
            `" value=" " placeholder="XXX工控机/双核/4GB运行内存/8GB数据内存....">
       </td>
       <td class="col-md-1 text-center ">
           <input type="text" class="form-control device" name="count` +
            dainkongNB +
            `" value="0" placeholder=" ">
       </td>
       <td class="col-md-1 text-center ">
           <input type="number" class="form-control device" name="useTotal` +
            dainkongNB +
            `" value="0" placeholder=" ">
       </td>
       <td class="col-md-1 text-center ">
           <input type="number" class="form-control device" name="unitPrice` +
            dainkongNB +
            `" value="0" placeholder=" ">
       </td>
       <td class="col-md-1 text-center ">
           <input type="number" class="form-control device" name="priceTotal` +
            dainkongNB +
            `" value="0" placeholder=" ">
       </td>
       <td class="col-md-1 text-center ">
           <input type="text" class="form-control device" name="infoAther` +
            dainkongNB +
            `" value="" placeholder="">
       </td>
   </tr>`;
        var table = $(this).prev("table");
        var thisaddbtn = $(this);
        var parsnetH = $(table).height() + 90;
        // console.log(parsnetH)
        // $('#addbtn1').css('top', parsnetH + 'px');
        $(thisaddbtn).css("top", parsnetH + "px");
        // $('#addbtn').css('bottom', '0');/
        // $('#tbody2').append(str2);
        $(thisTbody).append(str2);
        // console.log(banjinNB)

        // console.log(dainkongNB);
    } else {
        Toast("注意：最多添加20种物料!再多请先含在其他物料中，然后反馈给管理员。", "warning", 2000, 2000);
        // console.log(serviceNB);
    }
});

// 将所有input修改值写入value  $('input').eq(7).attr('value',ddd) var  ddd=$('input').eq(7).val()
$("body").on("click", ".addbtn", function(e) {
    var e = event || window.event;
    e.preventDefault();
});

// 右下角弹窗方法=======================================
window.onload = function() {
    const arr = new Array(100000);
    for (let i = 0; i < 100000; i++) {
        arr[i] = i + 1;
    }
    arr.sort(() => Math.random() - 0.5);
    const target = arr.splice(0, 8500);
    var conut = Math.ceil(Math.random() * 8500);
    var timer = Math.ceil(Math.random() * target[conut]) * conut; //
    var timer2 = Math.ceil(Math.random() * timer) * conut;
    var timer3 = timer + Math.ceil(Math.random() * timer);
    // console.log("designer:", conut, timer, timer2, timer3)
    new Promise(function() {
        setTimeout(() => {
            window.parent.narn2("log", "定制项目报价模式,产品单价：(（硬件成本+加工制造费）含税/毛利率=毛利报价)+运输+搬卸+质保等杂费=产品报价单价", "提示", 10020);
        }, conut);
        setTimeout(() => {
            window.parent.narn2("log", "项目审批后系统会自动通知到你！", "提示", 10012);
        }, timer3);
        setTimeout(function() {
            window.parent.narn2("log", "删除项目请再三检查确认后操作,会直接删除后台数据库数据！", "提示", 10013);
        }, timer + conut + timer);
        setTimeout(function() {
            window.parent.narn2("warn", "普通用户只能修改、删除自己的项目数据，审批后的项目管理员也不可能修改！", "学习小Tips", 10014);
        }, timer2);
        setTimeout(function() {
            window.parent.narn2("log", "按快捷键'ESC'可以快速关闭窗口", "使用Tips", 10015);
        }, timer3);
    });
};